trigger:
  none

schedules:
  - cron: 0 12 * * 1,4,6
    # CodeQL auto-injects into other pipelines and will do a scan if one hasn't
    # been done in 72 hours. These can cause timeouts, so we ensure that one has
    # already been performed. We can increase this to 4x/week or be more
    # sophisticated if the 72 hour period ending Thursday ("4" in the cron line)
    # causes a problem.
    displayName: 3x/week CodeQL/Semmle run
    branches:
      include:
      - main
    always: true

variables:
  - template: /eng/pipelines/common/variables.yml
  - name: Codeql.Cadence
    value: 0
  - name: Codeql.TSAEnabled
    value: True
  - name: Codeql.BuildIdentifier
    value: $(System.JobDisplayName)
  - name: Codeql.Language
    value: cpp,csharp,java,python

extends:
  template:  /eng/pipelines/common/templates/pipeline-with-resources.yml
  parameters:
    stages:
    - stage: Build
      jobs:

      #
      # Build CoreCLR runtime packs
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/global-build-job.yml
          buildConfig: release
          platforms:
          - linux_x64
          - windows_x64
          jobParameters:
            buildArgs: -s clr+libs+host+packs -c $(_BuildConfig)
            nameSuffix: AllSubsets_CoreCLR
            isOfficialBuild: ${{ variables.isOfficialBuild }}
            timeoutInMinutes: 360
            isManualCodeQLBuild: true

      #
      # Build Mono runtime packs
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/global-build-job.yml
          buildConfig: release
          runtimeFlavor: mono
          platforms:
          - linux_x64
          - windows_x64
          jobParameters:
            buildArgs: -s mono+libs+host+packs -c $(_BuildConfig)
            nameSuffix: AllSubsets_Mono
            isOfficialBuild: ${{ variables.isOfficialBuild }}
            timeoutInMinutes: 360
            isManualCodeQLBuild: true
